package com.wzdigit.wms.basic.enums;

import java.util.*;

/**
 * 货品参数枚举类
 * @author yangdongjie
 * @LocationEnum.java
 * @2020年12月30日下午4:04:17
 */
public enum SkuEnum implements BaseEnum {
	
	/** 
	 * BarcodeControl
	 * 条码管控类型：
	 */
	BARCODE_CONTROL_A(1, "单品", "BarcodeControl"), 
	BARCODE_CONTROL_B(2, "批次", "BarcodeControl"), 
	
	/** 
	 * BarcodeParser
	 * 条码解析方式：
	 */
	BARCODE_PARSER_A(11, "序号范围解析", "BarcodeParser"), 
	BARCODE_PARSER_B(12, "条码解析", "BarcodeParser"),
	
	/** 
	 * DataSource
	 * 来源方式：
	 */
	DATA_SOURCE_A(21, "ERP同步", "DataSource"), 
	DATA_SOURCE_B(22, "手动导入", "DataSource"),
	
	/** 
	 * ReserveCode
	 * 库位指定方式：
	 */
	RESERVE_CODE_A(31, "人工指定库位", "ReserveCode"), 
	RESERVE_CODE_B(32, "收货时计算库位", "ReserveCode"),
	RESERVE_CODE_C(33, "上架时计算库位", "ReserveCode"),
	
	/** 
	 * CalculateCode
	 * 体积重量计算方式：
	 */
	CALCULATE_CODE_A(41, "录入整票单证总量", "CalculateCode"), 
	CALCULATE_CODE_B(42, "按产品手工录入", "CalculateCode"),
	CALCULATE_CODE_C(43, "按产品自动计算", "CalculateCode");
	
	/**
	 * 枚举值
	 */
	public int code;

	/**
	 * 枚举名称
	 */
	public String enumName;

	/**
	 * 枚举实体类属性描述
	 */
	public String description;

	SkuEnum(String enumName, String description) {
		this.enumName = enumName;
		this.description = description;
	}

	SkuEnum(int code, String enumName, String description) {
		this.code = code;
		this.enumName = enumName;
		this.description = description;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public static SkuEnum getEnumByCode(int enumCode) {
		SkuEnum[] values = SkuEnum.values();
		SkuEnum samplingEnum = null;

		for (SkuEnum value : values) {
			if (value.getCode() == enumCode) {
				samplingEnum = value;
			}
		}
		return samplingEnum;
	}

	public static SkuEnum getEnumByName(String enumName) {
		SkuEnum[] values = SkuEnum.values();
		SkuEnum repairEnum = null;

		for (SkuEnum value : values) {
			if (value.getEnumName() == enumName) {
				repairEnum = value;
			}
		}
		return repairEnum;
	}

	public String getEnumName() {
		return enumName;
	}

	public void setEnumName(String enumName) {
		this.enumName = enumName;
	}

	public static Map<Integer, String> getEnumByDescription(String enumDescription) {
		Map<Integer, String> enumMap = new HashMap<Integer, String>();
		SkuEnum[] values = SkuEnum.values();
		for (SkuEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				enumMap.put(value.getCode(), value.getEnumName());
			}
		}
		return enumMap;
	}
	
	public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		SkuEnum[] values = SkuEnum.values();
		for (SkuEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				Map<String, Object> enumMap = new HashMap<String, Object>(2);
				enumMap.put("code", value.getCode());
				enumMap.put("name", value.getEnumName());
				list.add(enumMap);
			}
		}
		return list;
	}
}
